package com.core.travelAgent.bo;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.common.web.SelectJson;
import com.core.travelAgent.dao.AgentRelationDao;
import com.core.travelAgent.dao.TravelAgentDao;
import com.core.travelAgent.dto.TravelAgentSearchCondition;
import com.core.travelAgent.pojo.AgentRelation;
import com.core.travelAgent.pojo.TravelAgent;
@Service
public class TravelAgentBo {
	@Resource
	private TravelAgentDao travelAgentDao;
	@Resource
	private AgentRelationDao agentRelationDao;
	
	public void add(TravelAgentSearchCondition sc) {
		travelAgentDao.add(sc);
	}
	public void update(TravelAgentSearchCondition sc) {
		travelAgentDao.update(sc);
	}
	public void del(String id){
		travelAgentDao.del(id);
	}
	public TravelAgentSearchCondition getById(TravelAgentSearchCondition sc){
		return travelAgentDao.getById((long)sc.getId());
	}
	//其他界面应用的搜索
		public List<SelectJson> searchDtoList(TravelAgentSearchCondition sc){
			return  travelAgentDao.searchDtoList(sc);
		}
		//获取展示页的数据
		public List<TravelAgentSearchCondition> getAgentSearchConditions(TravelAgentSearchCondition sc){
			return travelAgentDao.getAgentSearchConditions(sc);
		}
		//获取所有记录
		public Integer getAllRecodeCnt(TravelAgentSearchCondition sc){
			return travelAgentDao.getAllRecodeCnt(sc);
		}
//		旅行社和送签社关系的方法
		public List<AgentRelation> getInterval(AgentRelation agentRelation){
			return agentRelationDao.getRelation(agentRelation);
		}
		public void addRelation(AgentRelation agentRelation){
			agentRelationDao.add(agentRelation);
		}
		public void updateRelation(AgentRelation agentRelation){
			agentRelationDao.update(agentRelation);
		}
		public void delRelation(AgentRelation agentRelation){
			agentRelationDao.del(agentRelation);
		}
		public AgentRelation getRelationById(long id){
			return agentRelationDao.getRelationById(id);
		}
		public int searchRelationCnt(AgentRelation agentRelation){
			return agentRelationDao.searchRelationCnt(agentRelation.getTravelAgentId());
		}
//		其他界面获取该用户所对应的旅行社的送签社信息
		public List<SelectJson> getUserSendAgent(AgentRelation agentRelation){
			return agentRelationDao.getUserSendAgent(agentRelation);
		}
		public Integer getUserSendAgentCnt(AgentRelation agentRelation){
			return agentRelationDao.getUserSendAgentCnt(agentRelation);
		}
		public String getNameById(Long id) {
			TravelAgentSearchCondition temp= travelAgentDao.getNameById(id);
			if(temp==null){
				temp.setTravelAgentName(" ");
			}
			return temp.getTravelAgentName();
		}
		
}
